package com.kevin.chat.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class LoginController {

    @RequestMapping("/doLogin")
    public String doLogin(HttpServletRequest request) {
        String loginName = request.getParameter("loginName");
        System.out.println("loginName" + loginName);
        if (loginName == null || loginName.equals("")){
            return login();
        }else{
            request.setAttribute("loginName", loginName);
            return "chat";
        }
    }
    @RequestMapping("/")
    public String login() {
        return "login";
    }
}
